package org.mfw.obj.mob
{
	import org.mfw.interfaces.obj.mob.IAlbum;
	import org.mfw.interfaces.obj.mob.ISong;

	public class Song extends MediaObject implements ISong
	{
		private var _length:Number;
		private var _URL:String;
		private var _track:Number;
		private var _size:Number;
		private var _artist:Artist;
		private var _album:Album;
		
		public function Song(object:Object)
		{
			super();
			this._ID=object.id;
			this._length=object.time;
			this._name=object.title;
			this._URL=object.url;
			this._track=object.track;
			this._size=object.size;
			if (object.hasOwnProperty("album")){
				object.album.art = object.art;
				this._album= new Album(object.album);
			}
			if (object.hasOwnProperty("artist")) {
				this._artist= new Artist(object.artist);
			}
		}
		
		
		public function get length():Number
		{
			return this._length;
		}
		
		public function get lengthAsString():String
		{
			var time:Number = this._length/60;
			time = Math.round(time*100)/100;
			var output:String = new String(time);
			output.replace(".",":");
			return output;
		}
		
		public function set length(value:Number):void {
			this._length=value;
		}
		
		public function get songURL():String {
			return this._URL;
		}
		
		public function get album():IAlbum {
			return this._album;
		}
		
	}
}